package v1;

/**
 * 对象适配器模式
 * 需求：
 * 将家用220v电压转换成手机能使用的5v电压
 */
public class AdapterTest1 {
    public static void main(String[] args) {
        Adaptee adaptee = new Adaptee();
        Target target = new Adapter(adaptee);
        target.output5v();
    }
}
class Adaptee{
    private int output220v;
    public int output220v(){
        return 220;
    }
}
interface Target{
    int output5v();
}
class Adapter implements Target{
    private Adaptee adaptee;

    public Adapter(Adaptee adaptee) {
        this.adaptee = adaptee;
    }

    @Override
    public int output5v() {
        int i = adaptee.output220v();
        // ....
        System.out.println(String.format("原始电压：%d -> %d",i,5));
        return 5;
    }
}